package com.candy.actiivemq.jms;

import lombok.extern.slf4j.Slf4j;
import org.apache.activemq.ActiveMQConnectionFactory;

import javax.jms.*;

/**
 * @author: candy
 * @date: 2020/9/20
 * @description :
 **/
@Slf4j
public class JmsProduct {

    private final static String URL = "tcp://192.168.0.108:61616";


    public static void main(String[] args) throws JMSException {

        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(URL);
        Connection connection = connectionFactory.createConnection();
        connection.start();
        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        Queue syncQueue = session.createQueue("syncQueue");
        MessageProducer producer = session.createProducer(syncQueue);
        int deliveryMode = producer.getDeliveryMode();
        TextMessage message = session.createTextMessage();

        for (int i = 0; i < 5; i++) {
            message.setText(String.valueOf(i));
            producer.send(message);
        }
        producer.close();
        session.close();
        connection.close();

    }
}
